﻿
@using HynuIOTA.Entity
@using HynuIOTA.Entity.FormatEntity

@{
    List<BlogArticle> blogList = ViewBag.blogList;
    PageData pageData = ViewBag.pageData;
    string defaultImg = "/Images/icon-iot.png";
}
<div class="title">
    <h3 style="line-height: 1.3">@ViewBag.Title</h3>
</div>
@{
    foreach (var item in blogList)
    {
        var url = Url.RouteUrl("ShowArticle", new { Id = item.Id });

        <article class="excerpt excerpt-1">
            <a class="focus" href="@url" title="@item.Title" target="_blank">
                <img class="thumb" data-original="/Images/icon-iot.png" src="@(item.image == null?defaultImg:item.image)" alt="@item.Title">
            </a>
            <header>
                <a class="cat" href="@Url.Content("~/Blogs/Blog/UBlogList/")@item.Id">@item.User.UserName - 的分享<i></i></a>
                <h2><a href="@url" title="@item.Title" target="_blank">@item.Title</a></h2>
            </header>
            <p class="meta">
                <time class="time"><i class="glyphicon glyphicon-time"></i>@item.WriteTime</time>
                <span class="views"><i class="glyphicon glyphicon-eye-open"></i> @item.VisitCount</span> <a class="comment" title="评论"><i class="glyphicon glyphicon-comment"></i> @item.CommentCount</a>
            </p>
            <p class="note">@item.Summary</p>
        </article>
    }
}
<nav class="pagination">
    <ul>
        <li class="prev-page"></li>
        @{
            var count = Math.Ceiling(pageData.PageCount / (double)pageData.PageSize);
            var next = pageData.PageIndex + 1 > count ? count : pageData.PageIndex + 1;
            for (int i = 1; i <= count; i++)
            {
                if (i == pageData.PageIndex)
                {
                    <li class="active"><span>@i</span></li>
                }
                else
                {
                    <li><a href="?page=@i">@i</a></li>
                }
            }
        }
        <li class="next-page"><a href="?page=@next">下一页</a></li>
        <li><span>共 @count 页</span></li>
    </ul>
</nav>
